package cn.com.header.zbpk.account.controller;

import cn.com.header.core.support.web.JsonViewData;
import cn.com.header.core.vo.TreeVO;
import cn.com.header.zbpk.account.service.IAuthorityService;
import cn.com.header.zbpk.web.CommonController;
import com.google.common.collect.Maps;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author Yuanyifeng
 * @date 2017-11-18
 * @time 14:09
 */
@RestController
@RequestMapping(value = "/manage/auth", method ={RequestMethod.POST,RequestMethod.GET})
public class AuthorityController extends CommonController {
    @Autowired
    private IAuthorityService authorityService;
    String s;

    /**
     * 获取当前用户的权限
     * @return
     */
    @RequestMapping("getCurrrentAuth")
    public JsonViewData getCurrrentAuth(){
        Map<String, Object> resultMap = Maps.newHashMapWithExpectedSize(1);
        List<TreeVO> authList=authorityService.getAuthByUserIdAndParentId(getCurrentUserId());
        resultMap.put("authList",authList);
        return setJsonViewData(resultMap);
    }
}
